import java.util.ArrayList;

public class Board {
	ArrayList<int[]> slots;
	ArrayList<Placed[]> placed;
	int[] sequenceToGuess;

	Board() {
		sequenceToGuess = null;
		slots = new ArrayList<int[]>();
		placed = new ArrayList<Placed[]>();
	}

	public void Reset() {
		slots.clear();
	}

	void Play(int[] sequence) {
		slots.add(sequence);
		placed.add(Compare(sequence, sequenceToGuess));
	}

	void SetSequenceToGuess(int[] sequence) {
		sequenceToGuess = sequence.clone();
	}

	Boolean IsFull() {
		return (slots.size() >= 10);
	}

	Boolean IsReadyToPlay() {
		return (sequenceToGuess != null);
	}

	public void Display() {
		for (int i = 0; i < slots.size(); i++) {
			int[] slot = slots.get(i);
			Placed[] result = placed.get(i);

			for (int j : slot) {
				System.out.print(j);
			}

			System.out.print(" : ");
			for (Placed r : result) {
				switch (r) {
				case OK:
					System.out.print("o");
					break;
				case ELSEWHERE:
					System.out.print("x");
					break;
				default:
					System.out.print(".");
					break;
				}
			}
			System.out.println();
		}
	}

	Placed[] Compare(int[] proposed, int[] toGuess) {
		Placed[] result = new Placed[4];

		for (int i = 0; i < 4; i++) {
			result[i] = Placed.NOWHERE;
			int p = proposed[i];
			for (int j = 0; j < 4; j++) {
				int g = toGuess[j];
				if (p == g) {
					if (i == j) {
						result[i] = Placed.OK;
						j = 999;
					} else {
						result[i] = Placed.ELSEWHERE;
					}
				}
			}
		}
		return result;
	}

}
